﻿
@{
    ViewBag.Title = "Index";
}

<h2>SignalR测试</h2>
<div id="content"></div>
    

@section scripts{
    <script src="~/Scripts/jquery-3.7.0.min.js"></script>
    <script src="~/Scripts/jquery.signalR-2.4.3.min.js"></script>
    <script>
        var conn = $.connection("/chats");

        //连接成功
        conn.start().done(function () {
            conn.send('我来了');
        });

        // 接受到消息
        conn.received(function (msg) {
            $('#content').append("<p>" + msg + "</p>");
        })
    </script>
    
    
    }



